# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libcap
pkgver=2.64
pkgrel=1
pkgdesc="POSIX 1003.1e capabilities"
arch="all"
license="BSD-3-Clause OR GPL-2.0-only"
url="https://sites.google.com/site/fullycapable/"
depends_dev="linux-headers"
makedepends_build="linux-headers perl bash"
makedepends_host="$depends_dev"
makedepends="$makedepends_build $makedepends_host"
subpackages="$pkgname-doc $pkgname-static $pkgname-dev $pkgname-utils libcap2"
source="https://kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-$pkgver.tar.xz"

build() {
	make BUILD_CC=gcc CC="${CC:-gcc}" lib=lib prefix=/usr GOLANG=no \
		DESTDIR="$pkgdir"
}

check() {
	make GOLANG=no test
}

package() {
	# backwards compatibility for things that depended on 'libcap'
	depends="libcap2=$pkgver-r$pkgrel $pkgname-utils=$pkgver-r$pkgrel"

	make lib=lib prefix=/usr RAISE_SETFCAP=no GOLANG=no DESTDIR="$pkgdir" \
		install
	# Fix perms
	chmod -v 0755 "$pkgdir"/usr/lib/libcap.so.$pkgver
}

utils() {
	pkgdesc="$pkgdesc (utils)"

	amove usr/sbin
}

libcap2() {
	replaces="$pkgname<2.64-r1"
	default_libs
}

sha512sums="
3c5cf478cef249585ee1a0dfd75c6b41b0daf4e1ecb59dce894eac5523841aa79ca499be4161f73193dd8e7363edcd51063f3e281930cee939ebd50983eecbaf  libcap-2.64.tar.xz
"
